home *** CD-ROM | disk | FTP | other *** search
/ Ultra Pack / UltraComputing Partner Applications.iso / SunLabs / tclTK / src / tcl7.4 / compat / fixstrtod.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-28  |  859 b   |  37 lines

  1. /* 
  2.  * fixstrtod.c --
  3.  *
  4.  *    Source code for the "fixstrtod" procedure.  This procedure is
  5.  *    used in place of strtod under Solaris 2.4, in order to fix
  6.  *    a bug where the "end" pointer gets set incorrectly.
  7.  *
  8.  * Copyright (c) 1995 Sun Microsystems, Inc.
  9.  *
  10.  * See the file "license.terms" for information on usage and redistribution
  11.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  12.  */
  13.  
  14. static char sccsid[] = "@(#) fixstrtod.c 1.3 95/06/27 16:19:56";
  15.  
  16. #undef strtod
  17.  
  18. /*
  19.  * Declare strtod explicitly rather than including stdlib.h, since in
  20.  * somes systems (e.g. SunOS 4.1.4) stdlib.h doesn't declare strtod.
  21.  */
  22.  
  23. extern double strtod();
  24.  
  25. double
  26. fixstrtod(string, endPtr)
  27.     char *string;
  28.     char **endPtr;
  29. {
  30.     double d;
  31.     d = strtod(string, endPtr);
  32.     if ((*endPtr != string) && ((*endPtr)[-1] == 0)) {
  33.     *endPtr -= 1;
  34.     }
  35.     return d;
  36. }
  37.